<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //es5组合继承-伪经典继承  原型链继承+借用构造函数继承
    //父类
    //构造函数  属性写在构造函数里
    //function User(name,pass){
    //    this.name = name;
    //    this.pass  = pass;
    //}

    ////方法写在原型中
    //User.prototype.showName = function(){
    //    console.log(this.name);
    //}
    //User.prototype.showPass = function(){
    //    console.log(this.pass);
    //}

    //// 子类

    //function VipUser(name,pass,level){
    //    //借用构造函数来继承父类的属性  call apply bind的区别
    //    User.call(this,name,pass)
    //    User.apply(this,[name,pass])
    //    this.level = level;//特有属性
    //}

    ////原型链继承  方法的继承
    //VipUser.prototype = new User()
    //VipUser.prototype.constructor = VipUser;
    
    //VipUser.prototype.showLevel = function(){
    //    console.log(this.level);
    //}

    //let v1 = new VipUser("king",123456,3)
    //v1.showName()
    //v1.showPass()
    //v1.showLevel()

    //es6的继承
    class User{
        //构造器
        constructor(name,pass){
            this.name = name;
            this.pass = pass;
        }
        showName(){
            console.log(this.name);//king
        }
        showPass(){
            console.log(this.pass); //123456
        }
    }
    //子类
    class VipUser extends User{
        constructor(name,pass,level){
            super(name,pass) //指向 this super 指向父类构造器
            this.level = level
        }
        showLevel(){
            console.log(this.level);//3
        }
    }
    let v1 = new VipUser("king",123456,3)
    v1.showName()
    v1.showPass()
    v1.showLevel()
    console.log(typeof VipUser) //function
</script>
</html>